<?php

error_reporting(E_ALL);

/**
 * ELEARNING - class.ModeloDetalle.php
 *
 * $Id$
 *
 * This file is part of ELEARNING.
 *
 * Automatically generated on 07.12.2011, 22:21:54 with ArgoUML PHP module 
 * (last revised $Date: 2010-01-12 20:14:42 +0100 (Tue, 12 Jan 2010) $)
 *
 * @author firstname and lastname of author, <author@example.org>
 */

if (0 > version_compare(PHP_VERSION, '5')) {
    die('This file was generated for PHP 5');
}

/**
 * include Conexion
 *
 * @author firstname and lastname of author, <author@example.org>
 */
require_once('class.Conexion.php');

/* user defined includes */
// section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BC2-includes begin
// section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BC2-includes end

/* user defined constants */
// section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BC2-constants begin
// section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BC2-constants end

/**
 * Short description of class ModeloDetalle
 *
 * @access public
 * @author firstname and lastname of author, <author@example.org>
 */
class ModeloDetalle
    extends Conexion
{
    // --- ASSOCIATIONS ---


    // --- ATTRIBUTES ---

    // --- OPERATIONS ---

    /**
     * Short description of method GetAllRows
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @return mixed
     */
    public function GetAllRows()
    {
        // section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BDF begin
		
        // section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BDF end
    }

    /**
     * Short description of method GetId
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function GetId($id)
    {
        // section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BE1 begin
		
		$sql1 = "SELECT idcurso,nombre,categoria, descrip, maestro  from cursos, (select iduser, nombre as maestro from usuarios) as tabla where idcurso=".$id." and usuarios_iduser = iduser;";            
       	$sql2 = "select idactividad, actividades.nombre, actividades.descrip , iddetalle
from actividades,(select * from detallecurso where cursos_idcurso =".$id." ) as detalle where detalle.actividades_idactividad=idactividad order by idactividad;";
		$sql3 = "select idactividad, actividades.nombre, actividades.descrip 
from actividades, cursos
where idcurso =".$id." and not exists(select * from detallecurso where actividades_idactividad = idactividad and cursos_idcurso = idcurso)
group by idactividad order by idactividad;";        
       	$arrayReturn[] =  $this->ejecutarQuery($sql1);
       	$arrayReturn[] =  $this->ejecutarQuery($sql2);
		$arrayReturn[] =  $this->ejecutarQuery($sql3);
       	return $arrayReturn;

        // section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BE1 end
    }

    /**
     * Short description of method InsertRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return mixed
     */
    public function InsertRow($curso,$id)
    {
        // section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BE5 begin
		$sql = "INSERT INTO detallecurso (
			cursos_idcurso,
			actividades_idactividad
			) VALUES (
			".$curso.",
			".$id."	
			)";
		$this->ejecutarQuery($sql);
		return mysql_insert_id();    
        // section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BE5 end
    }

    /**
     * Short description of method UpdateRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  datos
     * @return mixed
     */
    public function UpdateRow($datos)
    {
        // section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BE7 begin
        // section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BE7 end
    }

    /**
     * Short description of method DeleteRow
     *
     * @access public
     * @author firstname and lastname of author, <author@example.org>
     * @param  id
     * @return mixed
     */
    public function DeleteRow($id)
    {
        // section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BE9 begin
		$sql= "DELETE FROM detallecurso WHERE iddetalle=".$id;
		$this->ejecutarQuery($sql);
        // section 127-0-0-1--5d6a0cd9:1341be662d9:-8000:0000000000000BE9 end
    }

} /* end of class ModeloDetalle */

?>